JavaScript Starts with
startsWith() returns true if the string begins with the characters you pass, and false otherwise. An optional second argument lets you start the check at a given position. Case-sensitive.
Syntax
str.startsWith(search) Examples
| Input | Arguments | Output |
|---|---|---|
| "hello world" | "hello" | true |
| "hello" | "H" | false |
| ↳ Case-sensitive. | ||
When to use it
- Route or branch on URL prefixes.
- Detect protocols like "https://".
Gotchas
- Case-sensitive — normalise case first if needed.
Try it live
Type your input and see Starts with transform it instantly.
Want to go further? Chain Starts with with other functions in the visual Playground — pipe one output into the next and watch your data transform.